package com.jianda.service;

import com.jianda.view.windows.EditSerialPortWindows;
import com.jianda.view.windows.Mainwindows;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 事件处理类
 */
public class ActionListenerService implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        if (actionCommand.equals("设置串口参数")) {
            editSerialPortWindows();
        }
    }

    public static void editSerialPortWindows() {
        JFrame frame = Mainwindows.getInstance();

        // 关闭原窗口
        frame.setEnabled(false);
        frame.setModalExclusionType(Dialog.ModalExclusionType.NO_EXCLUDE);

        // 调用新窗口
        new EditSerialPortWindows(frame);
    }
}
